#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define PERFORM_DELEGATE_SELECTOR(delegate, selector, obj)   if ([(delegate) respondsToSelector:(selector)]) \
[(delegate) performSelector:(selector) withObject:obj];

#define ASSIGN_NSSTRING_TO_STDSTRING(ns, ss) ss = ns ? [ns UTF8String] : ""

#define ASSIGN_STDSTRING_TO_NSSTRING(ss, ns) ns = [NSString stringWithUTF8String:ss.c_str()]

#define SET_PARAM(dict, key, value) { if ((value) != nil) dict[(key)] = (value); }


#define kInvalidLatitude @(360.0)
#define kInvalidLongitude @(360.0)

@interface DataUtils : NSObject

+ (NSString*)appName;

+ (BOOL)isConnectedToNetwork;
+ (BOOL)isConnectedToWiFi;
+ (NSString*)networkName;

+ (NSString*)platformName;

+ (BOOL)isValidPassword:(NSString*)password;
+ (BOOL)isSamePassword:(NSString*)password withRepeatPassword:(NSString*)repeatPassword;
+ (BOOL)isValidEmail:(NSString*)email;
+ (BOOL)isValidMobliePhoneNumber:(NSString*)mpNumber;
+ (BOOL)isValidBirthday:(NSString*)birthday;
+ (BOOL)isValidScreenName:(NSString*)screenName;

// if fileSizeBits < 0.1M, short for ?.3K
// if fileSizeBits > 1M && fileSizeBits < 1G , short for ?.3M
// if fileSizeBits > 1G, short for ?.3G
+ (NSString*)fileSizeConvertToString:(unsigned long long)fileSizeBits;
+ (unsigned long long)fileSize:(NSString*)file;

+ (NSString*)tmpDirectory;
+ (NSString*)cachesDirectory;
+ (NSDate*)fileModificationDate:(NSString*)filePath;
+ (void)ensureDirectoryExist:(NSString*)dirPath;

+ (BOOL)hasEnoughFreeDiskspace;

+ (BOOL)isURLEscapeCharacter:(unichar)c;

+ (BOOL)haveURLEscapeCharacter:(NSString*)s;

+ (NSString*)escapeURLCharacter:(unichar)c;

+ (NSString*)escapeURLString:(NSString*)s;

+ (NSString*)escapeURLStringWithoutPercentChar:(NSString*)s;

+ (NSString*)stringOfTimeZone;

+ (BOOL)isTimeFormatVideoTitle:(NSString*)videoTitle;

+ (NSString*)yyyyMMddHHmmssLocalTime;

+ (NSTimeInterval)yyyyMMddHHmmssToSecondsSince1970:(NSString*)dateString;

+ (NSString *)defaultUserAgentString;

+ (NSString *)appVersion;

+ (NSString*)hexText:(NSString*)userId;

+ (BOOL)isValidAccessToken:(NSString*)error;

+ (NSString*)createUUID;

+ (NSString*)createUUIDRawBytes;

+ (NSString*)uuid2RawBytes:(NSUUID*)uuid;

+ (BOOL)isValidPid:(NSNumber*)pid;

+ (NSComparisonResult)compareVersion:(NSString*)version toVersion:(NSString*)toVersion;

+ (NSString *)md5HexDigest:(NSString *)code;

@end

